package com.play.ballen.home.vm

import androidx.lifecycle.MutableLiveData
import com.play.ballen.home.entity.ServiceInfo
import com.play.ballen.me.entity.WithDrawInfo
import com.play.ballen.network.ApiRepository
import com.play.ballen.network.BallenRxHelper
import com.yuven.appframework.network.RxSchedulerHelper
import com.yuven.appframework.util.addToDisposable
import com.yuven.baselib.component.viewmodel.BaseViewModel
import com.yuven.baselib.utils.Logger

class ServiceVM : BaseViewModel() {

    private val model = ApiRepository()
    val serviceInfo = MutableLiveData<ServiceInfo>()

    fun service() {
        model.service()
            .onErrorResumeNext(BallenRxHelper.HttpErrorHandleFunc())
            .compose(BallenRxHelper.transformResponse())
            .compose(RxSchedulerHelper.io_main())
            .subscribe({
                Logger.i("ServiceVM.service success")
                serviceInfo.value = it
            }, { throwable ->
                toastLiveData.value = throwable.message
                Logger.i("ServiceVM.service error,msg = ${throwable.message}")
            }).addToDisposable(compositeDisposable)
    }

}